package com.dragon.repository.domain.dto;

import com.baomidou.mybatisplus.annotation.TableField;
import com.dragon.repository.entity.Team;
import lombok.Data;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.dragon.common.util.BeanUtils;

import java.util.ArrayList;
import java.util.List;
import java.util.Date;


/**
 * @author sy
 */
@Data
@JsonInclude(JsonInclude.Include.NON_NULL)
public class TeamDTO {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value = "id")
    private Integer id;

    @ApiModelProperty(value = "用户id")
    private Integer adminId;

    @ApiModelProperty(value = "合同id")
    private Integer contractId;

    @ApiModelProperty(value = "有效时间")
    private Date effectiveTime;

    @ApiModelProperty("负责人（用户名称）")
    @TableField(exist = false)
    private String userName;

    @ApiModelProperty("部门名称")
    @TableField(exist = false)
    private String departName;


    public TeamDTO() {}

    public TeamDTO(Team entity) {
        BeanUtils.copyProperties(entity,this);
    }

    public static TeamDTO convert(Team entity) {
        return new TeamDTO(entity);
    }

    public static List<TeamDTO> convertList(List<Team> list) {
        List<TeamDTO> resultList = new ArrayList<>();
        for (Team entity : list) {
            resultList.add(new TeamDTO(entity));
        }
        return resultList;
    }}
